<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>部门管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../static/css/style.css" media="all">
    <script type="text/javascript" src="../../static/js/jquery.min.js"></script>
    <script type="text/javascript" src="../../layui/layui.all.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../static/js/jquery.cookie.js"></script>
    <script type="text/javascript" src="../../static/js/base.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../static/js/ax.js"></script>
</head>
<body class="bg_w">

<div class="layui-fluid">
    <div class="content-wrap">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-sm4">
                <label class="layui-form-label">岗位代码</label>
                <div class="layui-input-block">
                    <input type="text" name="code" id="code" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-col-sm4">
                <label class="layui-form-label">岗位名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" id="name" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-col-xs4">
                <button class="layui-btn add_btn" data-type="reload" onclick="searchBtn()" ><i class="layui-icon layui-icon-search"></i>搜索</button>
            </div>
        </div>
        <div class="layui-row">
            <table class="layui-hide" id="position" lay-filter="eventBtn"></table>
            <input type="hidden" name="positionId" id="positionId">
            <input type="hidden" name="positionName" id="positionName">
        </div>
    </div>
</div>

<script>

    //当前位置
    $('.content').css('padding-top',$('.position').innerHeight()+18);
    $(window).resize(function(){
        $('.content').css('padding-top',$('.position').innerHeight()+18);
    });


    var tableIns;
    var departmentCode;
    $(document).ready(function(){
        departmentCode= getQueryString('departmentCode');
        $("#positionId").val("");
        $("#positionName").val("");

        layui.use(['table', 'layer','element'], function(){
            var table = layui.table;
            tableIns =ax.VTable({
                elem: "#position",
                url:backendWebUrl+"/api/position/list?depCode="+departmentCode,
                method: 'POST',
                cols: [[
                    {field:'序列号', width:80, title: '序列号', sort: true,type:'numbers'},
                    {field:'name', title: '岗位名称'},
                    {field:'code', title: '岗位代码'},
                    {field:'depName', title: '所属部门'},
                    {field:'operatorName', title: '创建人'},
                    {field:'created', title: '创建时间'}
                ]]
            });

            //监听行单击事件（单击事件为：rowDouble）
            table.on('row(eventBtn)', function(obj){
                var postionJson = obj.data;
                $("#positionId").val(postionJson.id);
                $("#positionName").val(postionJson.name);
                //标注选中样式
                obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');
            });

        });
    });
    //搜索
    function searchBtn(){
        tableIns.reload({
            where: {
                name:$("#name").val(),
                code:$("#code").val(),
                depCode:departmentCode
            }
        });
    };
</script>
</body>
</html>